/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package application;

import controleur.ConnexionBD;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 *
 * @author James
 */
public class CommandeDAO {
    private static PreparedStatement pstmt;
    private static ResultSet results;
    
    public static ResultSet getCommandesOuvertesMembre(final String idMembre) {
        final String query = "select *, DATEDIFF(curdate(), date_de_retour) AS difference_dates "
                + "from commande where id_membre=? and id_etat=17 "
                + "order by date_de_retour";
        
        try {          
            pstmt = ConnexionBD.creerConnexion().prepareStatement(query);
            pstmt.setInt(1, Integer.parseInt(idMembre));
            results = pstmt.executeQuery();            
        } catch (Exception e) {
            return null;
        }
        return results;
    }
    
    public static ResultSet getCommandesOuvertes() {
        final String query = "select *, DATEDIFF(curdate(), date_de_retour) AS difference_dates "
                + "from commande where id_etat=17 "
                + "order by date_de_retour";
        
        try {          
            pstmt = ConnexionBD.creerConnexion().prepareStatement(query);
            results = pstmt.executeQuery();            
        } catch (Exception e) {
            return null;
        }
        return results;
    }
}
